package net.xiduth.game.player.dialogues.dominion;

import net.xiduth.game.WorldTile;
import net.xiduth.game.player.content.Magic;
import net.xiduth.game.player.dialogues.Dialogue;


public class DTRewards extends Dialogue {
	
	private int npcId;
	
	@Override
	public void start() {
		npcId = 0;
		sendNPCDialogue(npcId, 9827, "Welcome to the Dominion Tower, "  +
		"you currently have <col=C12006>" +player.getDP() +  " </col>DP." );
	}
	
	public void run(int interfaceId, int componentId) {
		if (stage == -1) {
		sendOptionsDialogue("Dominion Tower Guide", "What kind of rewards can I get?", "How much DP do I have?", "How do I get Dominion Points?", "Get me out of here!", "Cancel");
		stage = 2;
		} else if (stage == 2) {
		if(componentId == OPTION_1) {
		sendOptionsDialogue("Dominion Tower Guide", "Goliath gloves (black)", "Goliath gloves (white)", "Goliath gloves (yellow)" , "Goliath gloves (red)", "More Options...");
		stage = 4;
		}
		if(componentId == OPTION_2) {
		    sendNPCDialogue(npcId, 9827, "You currently have " +player.getDP() + " Dominion Points." );
			stage = -1;
		}
        if(componentId == OPTION_3) {
		    sendNPCDialogue(npcId, 9827, "Within the tower are many monsters. Each monster you defeat will give you 100 points. Your points can then be spent here." );
			stage = -1;
		}
        if(componentId == OPTION_4) {
        	Magic.sendNormalTeleportSpell(player, 0, 0, new WorldTile(3377,
					3087, 0));
			stage = 3;
		}
        if(componentId == OPTION_5) {
    		end();
			stage = 3;
		}
		} else if (stage == 3) {
			end();
		} else if (stage == 4) {
			if (componentId == OPTION_1) {
				if (player.getDP() >= 10000) {
				player.getInventory().addItem(22358, 1);
				player.setDP(player.getDP()
						- 10000);
				player.getInterfaceManager().closeChatBoxInterface();
				player.getInterfaceManager().sendChatBoxInterface(1189);
				player.getPackets().sendItemOnIComponent(1189, 1, 22358, 1);
				player.getPackets().sendIComponentText(1189, 4, "Purchase successful.");
				stage = 3;
				}else{
				sendNPCDialogue(npcId, 9827, "You need 10,000 Dominion Points to buy this item. " );
				stage = 3;
				}
				}
			if (componentId == OPTION_2) {
				if (player.getDP() >= 10000) {
				player.getInventory().addItem(22359, 1);
				player.setDP(player.getDP()
						- 10000);
				player.getInterfaceManager().sendChatBoxInterface(1189);
				player.getPackets().sendItemOnIComponent(1189, 1, 22359, 1);
				player.getPackets().sendIComponentText(1189, 4, "Purchase successful.");
				stage = 3;
				}else{
				sendNPCDialogue(npcId, 9827, "You need 10,000 Dominion Points to buy this item. " );
				stage = 3;
				}
				}
			if (componentId == OPTION_3) {
				if (player.getDP() >= 10000) {
				player.getInventory().addItem(22360, 1);
				player.setDP(player.getDP()
						- 10000);
				player.getInterfaceManager().sendChatBoxInterface(1189);
				player.getPackets().sendItemOnIComponent(1189, 1, 22360, 1);
				player.getPackets().sendIComponentText(1189, 4, "Purchase successful.");
				stage = 3;
				}else{
				sendNPCDialogue(npcId, 9827, "You need 10,000 Dominion Points to buy this item. " );
				stage = 3;
				}
				}
			if (componentId == OPTION_4) {
				if (player.getDP() >= 10000) {
				player.getInventory().addItem(22361, 1);
				player.setDP(player.getDP()
						- 10000);
				player.getInterfaceManager().sendChatBoxInterface(1189);
				player.getPackets().sendItemOnIComponent(1189, 1, 22361, 1);
				player.getPackets().sendIComponentText(1189, 4, "Purchase successful.");
				stage = 3;
				}else{
				sendNPCDialogue(npcId, 9827, "You need 10,000 Dominion Points to buy this item. " );
				stage = 3;
				}
				}
			if (componentId == OPTION_5) {
				sendOptionsDialogue("Dominion Tower Guide", "Swift gloves (black)", "Swift gloves (white)", "Swift gloves (yellow)" , "Swift gloves (red)", "More Options...");
				stage = 5;
				}
			} else if (stage == 5) {
			if (componentId == OPTION_1) {
				if (player.getDP() >= 8000) {
				player.getInventory().addItem(22362, 1);
				player.setDP(player.getDP()
						- 8000);
				player.getInterfaceManager().sendChatBoxInterface(1189);
				player.getPackets().sendItemOnIComponent(1189, 1, 22361, 1);
				player.getPackets().sendIComponentText(1189, 4, "Purchase successful.");
				stage = 3;
				}else{
				sendNPCDialogue(npcId, 9827, "You need 8,000 Dominion Points to buy this item. " );
				stage = 3;
				}
				}
			if (componentId == OPTION_2) {
				if (player.getDP() >= 8000) {
				player.getInventory().addItem(22363, 1);
				player.setDP(player.getDP()
						- 8000);
				player.getInterfaceManager().sendChatBoxInterface(1189);
				player.getPackets().sendItemOnIComponent(1189, 1, 22363, 1);
				player.getPackets().sendIComponentText(1189, 4, "Purchase successful.");
				stage = 3;
				}else{
				sendNPCDialogue(npcId, 9827, "You need 8,000 Dominion Points to buy this item. " );
				stage = 3;
				}
				}
			if (componentId == OPTION_3) {
				if (player.getDP() >= 8000) {
				player.getInventory().addItem(22364, 1);
				player.setDP(player.getDP()
						- 8000);
				player.getInterfaceManager().sendChatBoxInterface(1189);
				player.getPackets().sendItemOnIComponent(1189, 1, 22364, 1);
				player.getPackets().sendIComponentText(1189, 4, "Purchase successful.");
				stage = 3;
				}else{
				sendNPCDialogue(npcId, 9827, "You need 8,000 Dominion Points to buy this item. " );
				stage = 3;
				}
				}
			if (componentId == OPTION_4) {
				if (player.getDP() >= 8000) {
				player.getInventory().addItem(22365, 1);
				player.setDP(player.getDP()
						- 8000);
				player.getInterfaceManager().sendChatBoxInterface(1189);
				player.getPackets().sendItemOnIComponent(1189, 1, 22365, 1);
				player.getPackets().sendIComponentText(1189, 4, "Purchase successful.");
				stage = 3;
				}else{
				sendNPCDialogue(npcId, 9827, "You need 8,000 Dominion Points to buy this item. " );
				stage = 3;
				}
				}
			if (componentId == OPTION_5) {
				sendOptionsDialogue("Dominion Tower Guide", "Spellcaster gloves (black)", "Spellcaster gloves (white)", "Spellcaster gloves (yellow)" , "Spellcaster gloves (red)", "More Options...");
				stage = 6;
				}
			} else if (stage == 6) {
			if (componentId == OPTION_1) {
				if (player.getDP() >= 7500) {
				player.getInventory().addItem(22366, 1);
				player.setDP(player.getDP()
						- 7500);
				player.getInterfaceManager().sendChatBoxInterface(1189);
				player.getPackets().sendItemOnIComponent(1189, 1, 22366, 1);
				player.getPackets().sendIComponentText(1189, 4, "Purchase successful.");
				stage = 3;
				}else{
				sendNPCDialogue(npcId, 9827, "You need 7,500 Dominion Points to buy this item. " );
				stage = 3;
				}
				}
			if (componentId == OPTION_2) {
				if (player.getDP() >= 7500) {
				player.getInventory().addItem(22367, 1);
				player.setDP(player.getDP()
						- 7500);
				player.getInterfaceManager().sendChatBoxInterface(1189);
				player.getPackets().sendItemOnIComponent(1189, 1, 22367, 1);
				player.getPackets().sendIComponentText(1189, 4, "Purchase successful.");
				stage = 3;
				}else{
				sendNPCDialogue(npcId, 9827, "You need 7,500 Dominion Points to buy this item. " );
				stage = 3;
				}
				}
			if (componentId == OPTION_3) {
				if (player.getDP() >= 7500) {
				player.getInventory().addItem(22368, 1);
				player.setDP(player.getDP()
						- 7500);
				player.getInterfaceManager().sendChatBoxInterface(1189);
				player.getPackets().sendItemOnIComponent(1189, 1, 22368, 1);
				player.getPackets().sendIComponentText(1189, 4, "Purchase successful.");
				stage = 3;;
				}else{
				sendNPCDialogue(npcId, 9827, "You need 7,500 Dominion Points to buy this item. " );
				stage = 3;
				}
				}
			if (componentId == OPTION_4) {
				if (player.getDP() >= 7500) {
				player.getInventory().addItem(22369, 1);
				player.setDP(player.getDP()
						- 7500);
				player.getInterfaceManager().sendChatBoxInterface(1189);
				player.getPackets().sendItemOnIComponent(1189, 1, 22369, 1);
				player.getPackets().sendIComponentText(1189, 4, "Purchase successful.");
				stage = 3;
				}else{
				sendNPCDialogue(npcId, 9827, "You need 7,500 Dominion Points to buy this item. " );
				stage = 3;
				}
				}
			if (componentId == OPTION_5) {
				sendOptionsDialogue("Dominion Tower Guide", "Dominion sword", "Dominion crossbow", "Dominion staff" , "Back...");
				stage = 7;
				}
			} else if (stage == 7) {
			if (componentId == OPTION_1) {
				if (player.getDP() >= 12500) {
				player.getInventory().addItem(22346, 1);
				player.setDP(player.getDP()
						- 12500);
				player.getInterfaceManager().sendChatBoxInterface(1189);
				player.getPackets().sendItemOnIComponent(1189, 1, 22346, 1);
				player.getPackets().sendIComponentText(1189, 4, "Purchase successful.");
				stage = 3;
				}else{
				sendNPCDialogue(npcId, 9827, "You need 12,500 Dominion Points to buy this item. " );
				stage = 3;
				}
				}
			if (componentId == OPTION_2) {
				if (player.getDP() >= 12500) {
				player.getInventory().addItem(22348, 1);
				player.setDP(player.getDP()
						- 12500);
				player.getInterfaceManager().sendChatBoxInterface(1189);
				player.getPackets().sendItemOnIComponent(1189, 1, 22348, 1);
				player.getPackets().sendIComponentText(1189, 4, "Purchase successful.");
				stage = 3;
				}else{
				sendNPCDialogue(npcId, 9827, "You need 12,500 Dominion Points to buy this item. " );
				stage = 3;
				}
				}
			if (componentId == OPTION_3) {
				if (player.getDP() >= 12500) {
				player.getInventory().addItem(22347, 1);
				player.setDP(player.getDP()
						- 12500);
				player.getInterfaceManager().sendChatBoxInterface(1189);
				player.getPackets().sendItemOnIComponent(1189, 1, 22347, 1);
				player.getPackets().sendIComponentText(1189, 4, "Purchase successful.");
				stage = 3;
				}else{
				sendNPCDialogue(npcId, 9827, "You need 12,500 Dominion Points to buy this item. " );
				stage = 3;
				}
				}
			if (componentId == OPTION_4) {
				sendOptionsDialogue("Dominion Tower Guide", "Goliath gloves (black)", "Goliath gloves (white)", "Goliath gloves (yellow)" , "Goliath gloves (red)", "More Options...");
				stage = 4;
				}
	  }
	}

	@Override
	public void finish() {

	}

}